<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 对象是引用类型
        // 对象的浅拷贝
        // const info = {name: 'leon', age: 18}
        // const obj = Object.assign({}, info);

        // 对象的深拷贝
        const info = {name: 'leon', age: 18, friend: {name: 'coder'}};
        // 这样会返回一个新的对象给obj
        const obj = JSON.parse(JSON.stringify(info));
        info.friend.name = 'leo';
        console.log(obj.friend.name);

    </script>
</body>
</html>